package com.ibm.spatiotemp.test.requestServer.factory;

import java.util.LinkedList;

import com.ibm.spatiotemp.datamodel.config.BackendServerManager;
import com.ibm.spatiotemp.datamodel.config.PubSubMeta;
import com.ibm.spatiotemp.test.requestServer.JedisPubSubListener;
import com.ibm.spatiotemp.test.requestServer.RequestListener;

public class RequestListenerFactory {
	public static RequestListener getListenerInstance(PubSubMeta pubsubmeta){
		return new JedisPubSubListener(pubsubmeta);
	}
	
	public static RequestListener[] createListenerInstanceList(String resq_topic){
		RequestListener[] res = null;
		PubSubMeta[] pubsubs = BackendServerManager.getAllPubSubMetaByTopic(resq_topic);
		if(pubsubs.length > 0){
			res = new RequestListener[pubsubs.length];
			for (int i = 0; i < pubsubs.length; i++) {
				res[i] = getListenerInstance(pubsubs[i]);
			}
		}
		return res;
	}
}
